(function($){
    $(".move-box").on("mouseenter","img",function(){
        $(".move-box img").css("border","")
        $(this).css("border","1px solid #f0f")
        $(".jqzoom img").get(0).src=$(this).data("src");
    })
    $(".jqzoom").on("mouseenter",function(){
        leftx= ($(window).width()-1200)/2+231;
        $(".fangda").css({"display":"block","background":"#fff url('"+this.children[0].src+"') no-repeat"});
        $div=$("<div id='fangdajing'></div>");
        $div.css({"width":"200px","height":"200px","position":"absolute","backgroundImage":"url('img/ma/zoom1.jpg')","top":"0","left":"0"}).appendTo($(this))
        
        $(".jqzoom").on("mousemove",function(e){
            var top=e.pageY-279-100;
            var left=e.pageX-leftx;
            if(top>0){
                if(top>200){
                    top=200
                }
            }else{
                top=0;
            }
            if(left>0){
                if(left>200){
                    left=200
                }
            }else{
                left=0;
            }
            $("#fangdajing").css({"top":top+"px","left":left+"px"})
            var left1=-left+50;
            var top1=-top+20;
            $(".fangda").css({"backgroundPosition":left1+"px "+top1+"px"})
        })
    })
    $(".jqzoom").on("mouseleave",function(){
        $(".fangda").css("display","none")
        $("#fangdajing").remove();
    })
    var num=+$("#shuliang").val();
    var num1=+$("#jinsheng").text();
    $("#reduce").on("click",function(){
       
        if(num>1){
            num--;
        }
        console.log(num)
        $("#shuliang").val(num)
    })
    $("#add").on("click",function(){
        if(num<num1){
            num++; 
        }
        
         console.log(num)
         $("#shuliang").val(num)
     })
     
     var height1=parseInt($(".activeD").eq(0).css("height"))+800;
     var height2=height1+30;
     var height3=height2+36+parseInt($(".dc_cont").eq(1).css("height"))

      $(".s-left-list ul").on("click","li",function(){
        if($(this).index()==4){
            $(".tjsuccess").fadeIn()

        }else{
             $(".s-left-list li").removeClass("active1")
        $(this).addClass("active1")
        $(document).scrollTop(800);
         $(".product-detail-div").hide().eq($(this).index()).css("display","block")
        height1=parseInt($(".product-detail-div").eq($(this).index()).css("height"))+800;
         height2=height1+30;
        }

       
         
     })
     $(".dc_title").on("click","li",function(){
        $(".dc_title li").removeClass("active1")
        $(this).addClass("active1")
        $(".dc_cont").removeClass("active4").eq($(this).index()).addClass("active4")
        $("body").scrollTop(height2);
        height3=height2+36+parseInt($(".dc_cont").eq($(this).index()).innerHeight())
    })
    var top1=0;
     $(document).on("scroll",function(){
      
           top1=$(document).scrollTop();
          if(top1>=800&&top1<height1){
             $(".s-left-list").css({"position":"fixed","top":"0"})
             $(".s-left-box").css("marginTop","33px")
         }else if(top1<800||top1>height1){
            $(".s-left-list").css({"position":""})
            $(".s-left-box").css("marginTop","0")
         }
         
         if(top1<=height2||top1>height3){
            $(".dc_title").css({"position":""})
         }else if(top1>height2&&top1<height3){
            $(".dc_title").css({"position":"fixed","top":"0"})
         }

         if(top1>100){
             $(".backtop1").fadeIn()
         }else{
            $(".backtop1").fadeOut()
         }
         
     })
     $("#jrgwc").on("click",function(){
        $(".tjsuccess").fadeIn()
     })
    $(".backtop").on("click","#backTop",function(){
        $("html,body").animate({"scrollTop":0},500)
    })
    $("#jxgw").on("click",function(){
        $(".tjsuccess").fadeOut()
    })
    $("#close1").on("click",function(){
        $(".tjsuccess").fadeOut()
    })
    $(".tjsuccess-box").on("click",function(){
        $(".tjsuccess").fadeOut()
    })
    $tota=Number($(".active2 i").text())||12;
    $totapage=Math.ceil($tota/8);
    $("#page").paging({
        pageNo:1,
        totalPage: $totapage,
        totalSize: $tota,
        callback: function(num) {
            $.getJSON("php/page.php","page="+num,function(data){
            
                var html="";
                $.each(data['list'],function(i,v){
                  html+=`<li>
                    <div class="perse-img">
                        <img src="${v["photo"]}" alt=""width="50px">
                        <p title="${v["username"]}">${v["username"]}</p>
                    </div>
                    <div class="perse-content">
                        <div class="d-pf">
                            <span class="star"></span><i>${v["star"]}</i>
                            <span class="fr">
                                <a href="javascript:;">来自寺库IOS客户端</a>
                                <i>|</i>
                                <i>同品牌评价</i>
                                <i>|</i>
                                <i>${v["time"]}</i>
                            </span>
                        </div>
                        <p class="pl-cont">
                            ${v["content"]}
                        </p>
                        <div class="pl-photos">
                            <a href="##">${v["goods"]}</a>
                            <span>（${v["zan"]}）</span>
                        </div>
                    </div>
                    

                </li>`
                })
                $(".dc_list ul").html(html);
                $("body").animate({"scrollTop":"7990px"});
            })
        }
    })
    $(".dc_c_t").on("click","li",function(){
            $(".dc_c_t li").removeClass("active2");
            $(this).addClass("active2")
            $(".dc_list").removeClass("active4").eq($(this).index()).addClass("active4")
    })
    $("#page").on("click","a",function(){
        $("body").animate({"scrollTop":"8200px"});
    })




    $(".pl-photos span").on("click","a",function(){
        if(this.className=="zan"){
            var zan=Number(this.text);
         this.click=null;
        this.className="zan1"
        zan++;
        this.text=zan;
        }else{
            alert("只能赞一次哦")
        }
        
       
    })
}(jQuery))